package com.example.javabasic.suanfa.jiandan.打印子集;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @description 打印所有子集
 * @Author Lin FuYuan
 * @date 2021/7/26
 */
public class ChildSet {

    public static void main(String[] args) throws ParseException {
        int[] n = {1,2,3};

        List<List<Integer>> childs = childs(n);
        for (List<Integer> child : childs) {
            System.out.println(child);
        }
    }

    public static List<List<Integer>> childs(int[] n){
       List<List<Integer>> list = new ArrayList<>();
       list.add(new ArrayList<>());
        for (int i = 0; i < n.length; i++) {
            int x = list.size();
            for (int i1 = 0; i1 < x; i1++) {
                List<Integer> integers = new ArrayList<>(list.get(i1));
                integers.add(n[i]);
                list.add(integers);
            }
        }
        return list;
    }






}
